package assignment.ton.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.InputStream;

import javax.swing.ImageIcon;
import javax.swing.JEditorPane;
import javax.swing.JFrame;

/**
 * The help frame
 * 
 * @author Tim Stableford (tis4)
 */

public class HelpFrame extends JFrame{

	private static final long serialVersionUID = -1044541999474220602L;
	private JEditorPane jane;
	public HelpFrame() {
		this.setIconImage(new ImageIcon(getClass().getResource("ton_icon.gif"))
				.getImage());
		this.setTitle("TON Help");
		this.setResizable(true);
		jane = new JEditorPane(){
			private static final long serialVersionUID = -4258566813033061626L;
			public Dimension getPreferredSize() {
                return new Dimension(800, 600);
            }
        };
        jane.setEditable(false);
		jane.setContentType("text/html");
		this.add(jane, BorderLayout.NORTH);
		loadFile("/assignment/ton/help/index.html");
		pack();
	}
	private void loadFile(String f){
		InputStream is = getClass().getResourceAsStream(f);
		try {
	        String out = new java.util.Scanner(is).useDelimiter("\\A").next();
	        jane.setText(out);
	    } catch (java.util.NoSuchElementException e) {
	        
	    }
	}
}